package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.Admin;
import com.tjetc.entity.CareContent;
import com.tjetc.service.AdminService;
import com.tjetc.service.CareContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("carecontent")
public class CareContentController {
    @Autowired
    private CareContentService careContentService;

    @RequestMapping("detail/{careItemId}")
    public JsonResult detail(@PathVariable("careItemId") Long id) {
        return careContentService.findById(id);
    }
    @RequestMapping("page")
    public JsonResult page(@RequestParam(value = "name",required = false,defaultValue = "") String name,
                           @RequestParam(value = "type",required = false,defaultValue = "") Long type,
                           @RequestParam(value = "status",required = false,defaultValue = "") Long status,
                           @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                           @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return careContentService.findPage(name,type,status,pageNo,pageSize);
    }
    @RequestMapping("delete/{careItemId}")
    public JsonResult delete(@PathVariable("careItemId") Long id) {
        return careContentService.deleteById(id);
    }
    //接收参数格式是json
    @RequestMapping("save")
    public JsonResult save(@RequestBody CareContent careContent){
        return careContentService.save(careContent);
    }
}
